#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from datetime import datetime
from email.policy import default
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DateTime, Enum
from sqlalchemy.orm import relationship
from sqlalchemy.dialects.mysql import INTEGER
from db.database import Base
from common.utils import formatter

class Classroom(Base):
    __tablename__ = 'classroom'

    classroom_id = Column(INTEGER(11), primary_key=True)
    building_name = Column(String(100), nullable=False)
    room_number = Column(String(20))
    capacity = Column(INTEGER(11), nullable=False)
    location = Column(String(255), nullable=False)

    def __init__(self, building_name, room_number, capacity,
                 location):
        self.building_name = building_name
        self.room_number = room_number
        self.capacity = capacity
        self.location = location

    def __repr__(self):
        return 'Classroom:%s' % self.name

    def to_dict(self):
        new_dict = {}
        for c in self.__table__.columns:
            new_dict[formatter(c.name)] = getattr(self, c.name, None)
        return new_dict
